// BusinessException.java
package com.example.common.exception;

import com.example.common.constant.ErrorCode;
import com.example.common.dto.ApiResponse;

public class BusinessException extends RuntimeException {
    private final int code;
    
    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }
    
    public BusinessException(String message) {
        this(ErrorCode.INTERNAL_SERVER_ERROR, message);
    }
    
    public ApiResponse<?> toApiResponse() {
        return ApiResponse.error(code, this.getMessage());
    }
}